<?php
class AdminModel extends Model{
	
	public function get_rights($id)
	{
		return M('admin','','')->db('CONFIG1')->where('admin_id='.$id)->getField('admin_rights_id');
	}

	public function add_admin($data)
	{
		$data['admin_cid']  = $_SESSION['cid'];
		$data['time_insert']= time();
		$rs = M('admin','','DB_MEETING')->db('CONFIG1')->add($data);
		if(!$rs)
			return false;

		if($data['admin_rights_id'] == 2)
			$this->add_admin_rights($data,$rs);

		return $rs;
	}

	public function add_admin_rights($data,$rs)
	{
		$array = array(
			'admin_id'   =>$rs,
			'rights_id'	 =>implode(',',$data['meeting']),
			'rights_for' =>'meeting'
		);
		return M('admin_rights','','DB_MEETING')->db('CONFIG1')->add($array);
	}
		
}
?>